$(function () {
  $('#login_form').submit(function (e) {
    e.preventDefault();
    let formData = $('#login_form').serialize();
    let index;
    $.ajax({
      type: 'post',
      url: 'http://localhost:8080/api/v1/admin/user/login',
      beforeSend: function () {
        index = layer.load();
      },
      complete: function () {
        layer.close(index);
      },
      data: formData,
      success: function (resData) {
        if (resData.code != 200) {
          alert(resData.msg)
          return false;
        }
        console.log(resData.token);
        sessionStorage.setItem('big_news', resData.token);
        location.href = "./index.html";
      }
    })
  })
})